package com.april.controller;

import com.april.feign.ItemFeign;
import com.april.pojo.TbItemCat;
import com.april.utils.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 槐序 廿一
 * @Date: 2023-06-19
 * @Time: 20:15
 * @Description:
 */
@RestController
@RequestMapping("backend")
public class ItemCategoryController {

    @Resource
    ItemFeign itemFeign;

    @RequestMapping("itemCategory/selectItemCategoryByParentId")
    public Result selectItemCategoryByParentId(@RequestParam(value = "id", required = false, defaultValue = "0") Long id) {
        List<TbItemCat> tbItemCats = itemFeign.selectItemCategoryByParentId(id);
        if (tbItemCats == null || tbItemCats.size() == 0) {
            return Result.error("商品分类信息查询失败");
        }
        return Result.ok(tbItemCats);
    }
}
